home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Misc / GetDXVer / dxver.cpp next >
Encoding:
C/C++ Source or Header  |  2004-09-27  |  1.8 KB  |  60 lines

  1. //-----------------------------------------------------------------------------
  2. // File: DXVer.cpp
  3. //
  4. // Desc: Windows code that calls GetDXVersion and displays the results.
  5. //
  6. // (C) Copyright Microsoft Corp.  All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #include <windows.h>
  9. #include <stdio.h>
  10. #include <tchar.h>
  11.  
  12.  
  13.  
  14.  
  15. //-----------------------------------------------------------------------------
  16. // External function-prototypes
  17. //-----------------------------------------------------------------------------
  18. extern HRESULT GetDXVersion( DWORD* pdwDirectXVersion, TCHAR* strDirectXVersion, int cchDirectXVersion );
  19.  
  20.  
  21.  
  22.  
  23.  
  24. //-----------------------------------------------------------------------------
  25. // Name: WinMain()
  26. // Desc: Entry point to the program. Initializes everything, and pops
  27. //       up a message box with the results of the GetDXVersion call
  28. //-----------------------------------------------------------------------------
  29. int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  30.                     LPSTR strCmdLine, int nCmdShow )
  31. {
  32.     HRESULT hr;
  33.     TCHAR strResult[128];
  34.  
  35.     DWORD dwDirectXVersion = 0;
  36.     TCHAR strDirectXVersion[10];
  37.  
  38.     hr = GetDXVersion( &dwDirectXVersion, strDirectXVersion, 10 );
  39.     if( SUCCEEDED(hr) )
  40.     {
  41.         if( dwDirectXVersion > 0 )
  42.             _sntprintf( strResult, 128, TEXT("DirectX %s installed"), strDirectXVersion );
  43.         else
  44.             _tcsncpy( strResult, TEXT("DirectX not installed"), 128 );
  45.         strResult[127] = 0;
  46.     }
  47.     else
  48.     {
  49.         _sntprintf( strResult, 128, TEXT("Unknown version of DirectX installed") );
  50.         strResult[127] = 0;
  51.     }
  52.  
  53.     MessageBox( NULL, strResult, TEXT("DirectX Version:"), MB_OK | MB_ICONINFORMATION );
  54.     
  55.     return 0;
  56. }
  57.  
  58.  
  59.  
  60.